<?php

    class PageConfig
    {
        private static $jsConfig = array();

        /**
         * @return string
         */
        public static function GetLngMessagesJsPrefix()
        {
            return "messages_" . Core::GetLanguage();
        }

        /**
         * Returns URL to messages js file according to site language specified in context.
         * @return string
         */
        public static function GetLngMessagesJs($language = null)
        {
            $jsRelativePath = "";

            $lng = (!is_null($language)) ? $language : Core::GetLanguage();
            $jsRelativePath = self::GetLngMessageJsByLanguage( $lng );
            if ( $lng != SiteLanguage::EN )
            {
                $jsAbsolutePath = ROOT_PATH . "content/js/" . $jsRelativePath;
                if ( !file_exists( $jsAbsolutePath ) )
                {
                    $jsRelativePath = self::GetLngMessageJsByLanguage( SiteLanguage::EN );
                }
            }

            return $jsRelativePath;
        }

        /**
         * Returns relative file path to messages js by specified language.
         * @param string $language
         * @return string
         */
        private static function GetLngMessageJsByLanguage( $language )
        {
            $messagesRelativePathPattern = "lng/%LANGUAGE%/messages.js";
            return str_replace( "%LANGUAGE%", $language, $messagesRelativePathPattern );
        }
    }

?>